package com.cloudsigns.factorymanager2.produce.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.cloudsigns.factorymanager2.BaseActivity;
import com.cloudsigns.factorymanager2.R;
import com.cloudsigns.factorymanager2.cusenum.CommonEnum;
import com.cloudsigns.factorymanager2.engineering.adapter.GridAdapter;
import com.cloudsigns.factorymanager2.produce.bean.WorkPartBean;
import com.cloudsigns.factorymanager2.produce.bean.WorkPartDailyFeedbackBean;
import com.cloudsigns.factorymanager2.produce.bean.WorkPartFeedbackResponse;
import com.cloudsigns.factorymanager2.produce.bean.WorkPartOrderBean;
import com.cloudsigns.factorymanager2.produce.bean.WorkPartScheduleBean;
import com.cloudsigns.factorymanager2.produce.iview.IProductNormalFeedbackConfirmView;
import com.cloudsigns.factorymanager2.produce.iview.IProductUnusualFeedbackConfirmView;
import com.cloudsigns.factorymanager2.produce.iview.IProductUnusualFeedbackReplyConfirmView;
import com.cloudsigns.factorymanager2.produce.iview.produce_team.IWorkPartDetailView;
import com.cloudsigns.factorymanager2.produce.iview.produce_team.IWorkPartFeedbackDetailView;
import com.cloudsigns.factorymanager2.produce.presenter.ProductNormalFeedbackConfirmPresenter;
import com.cloudsigns.factorymanager2.produce.presenter.ProductUnusualFeedbackConfirmPresenter;
import com.cloudsigns.factorymanager2.produce.presenter.ProductUnusualFeedbackReplyConfirmPresenter;
import com.cloudsigns.factorymanager2.produce.presenter.produce_team.WorkPartDetailPresenter;
import com.cloudsigns.factorymanager2.produce.presenter.produce_team.WorkPartFeedbackDetailPresenter;
import com.cloudsigns.factorymanager2.project.utils.ConstantUtil;
import com.cloudsigns.factorymanager2.project.utils.DateUtil;

import java.util.List;

public class ProduceFeedbackDetailsActivity extends BaseActivity implements IWorkPartFeedbackDetailView, IProductNormalFeedbackConfirmView, IProductUnusualFeedbackConfirmView, IProductUnusualFeedbackReplyConfirmView, IWorkPartDetailView {
    private RelativeLayout rl_back;
    private TextView tv_title;
    private TextView tv_workpart_name, tv_product_name, tv_order_information, tv_submit_person, tv_submit_time;
    private TextView btn_submit;
    private LinearLayout ll_bottom;
    private LinearLayout ll_modify_plan;
    private ImageView img_modify_plan;
    private View v_1;
    private RelativeLayout rl_plan_infor;

    private LinearLayout ll_normal_feedback, ll_plan_feedback, ll_machin_feedback, ll_apply_adjust, ll_apply_return, ll_apply_scrap;

    /*正常反馈*/
    private TextView tv_normal_feedback_type, tv_normal_plan_amount, tv_normal_daily_output, tv_normal_feedback_content;
    private GridView normal_gridView;

    /*计划反馈*/
    private TextView tv_plan_feedback_type, tv_plan_unusual_classify, tv_plan_amount, tv_plan_daily_output, tv_plan_unfinished_reason, tv_plan_advice;

    /*加工反馈*/
    private TextView tv_machin_feedback_type, tv_machin_unusual_classify, tv_machin_unusual_reason, tv_machin_day_number, tv_machin_advice;
    private GridView machin_gridView;

    /*申请调整*/
    private TextView tv_adjust_feedback_type, tv_apply_adjust_day, tv_apply_adjust_reason;

    /*申请返工*/
    private TextView tv_return_feedback_type, tv_apply_return_num,tv_apply_return_day, tv_apply_return_reason;
    private GridView return_gridView;

    /*申请报废*/
    private TextView tv_scrap_feedback_type, tv_apply_scrap_num,tv_apply_scrap_day, tv_apply_scrap_reason;
    private GridView scrap_gridView;

    private GridAdapter gridAdapter;

    private WorkPartFeedbackResponse workPartFeedbackResponse;
    private WorkPartDailyFeedbackBean workPartDailyFeedbackBean;

    private WorkPartFeedbackDetailPresenter workPartFeedbackDetailPresenter;
    private ProductNormalFeedbackConfirmPresenter productNormalFeedbackConfirmPresenter;
    private ProductUnusualFeedbackConfirmPresenter productUnusualFeedbackConfirmPresenter;
    private ProductUnusualFeedbackReplyConfirmPresenter productUnusualFeedbackReplyConfirmPresenter;
    private WorkPartDetailPresenter workPartDetailPresenter;

    private WorkPartBean workPartBean;


    @Override
    protected void onBaseCreate(Bundle savedInstanceState) {
        setContentView(R.layout.layout_produce_feedback_detail);
    }

    @Override
    protected void initView(Bundle savedInstanceState) {
        rl_back = findViewById(R.id.rl_back);
        tv_title = findViewById(R.id.tv_title);
        tv_workpart_name = findViewById(R.id.tv_workpart_name);
        tv_product_name = findViewById(R.id.tv_product_name);
        tv_order_information = findViewById(R.id.tv_order_information);
        tv_submit_person = findViewById(R.id.tv_submit_person);
        tv_submit_time = findViewById(R.id.tv_submit_time);
        btn_submit = findViewById(R.id.btn_submit);
        ll_bottom = findViewById(R.id.ll_bottom);
        ll_modify_plan = findViewById(R.id.ll_modify_plan);
        img_modify_plan = findViewById(R.id.img_modify_plan);
        v_1=findViewById(R.id.v_1);
        rl_plan_infor=findViewById(R.id.rl_plan_infor);

        ll_normal_feedback = findViewById(R.id.ll_normal_feedback);
        ll_plan_feedback = findViewById(R.id.ll_plan_feedback);
        ll_machin_feedback = findViewById(R.id.ll_machin_feedback);
        ll_apply_adjust = findViewById(R.id.ll_apply_adjust);
        ll_apply_return = findViewById(R.id.ll_apply_return);
        ll_apply_scrap = findViewById(R.id.ll_apply_scrap);

        tv_normal_feedback_type = findViewById(R.id.tv_normal_feedback_type);
        tv_normal_plan_amount = findViewById(R.id.tv_normal_plan_amount);
        tv_normal_daily_output = findViewById(R.id.tv_normal_daily_output);
        tv_normal_feedback_content = findViewById(R.id.tv_normal_feedback_content);
        normal_gridView = findViewById(R.id.normal_gridView);


        tv_plan_feedback_type = findViewById(R.id.tv_plan_feedback_type);
        tv_plan_unusual_classify = findViewById(R.id.tv_plan_unusual_classify);
        tv_plan_amount = findViewById(R.id.tv_plan_amount);
        tv_plan_daily_output = findViewById(R.id.tv_plan_daily_output);
        tv_plan_unfinished_reason = findViewById(R.id.tv_plan_unfinished_reason);
        tv_plan_advice = findViewById(R.id.tv_plan_advice);


        tv_machin_feedback_type = findViewById(R.id.tv_machin_feedback_type);
        tv_machin_unusual_classify = findViewById(R.id.tv_machin_unusual_classify);
        tv_machin_unusual_reason = findViewById(R.id.tv_machin_unusual_reason);
        tv_machin_day_number = findViewById(R.id.tv_machin_day_number);
        tv_machin_advice = findViewById(R.id.tv_machin_advice);
        machin_gridView = findViewById(R.id.machin_gridView);


        tv_adjust_feedback_type = findViewById(R.id.tv_adjust_feedback_type);
        tv_apply_adjust_day = findViewById(R.id.tv_apply_adjust_day);
        tv_apply_adjust_reason = findViewById(R.id.tv_apply_adjust_reason);


        tv_return_feedback_type = findViewById(R.id.tv_return_feedback_type);
        tv_apply_return_num = findViewById(R.id.tv_apply_return_num);
        tv_apply_return_day=findViewById(R.id.tv_apply_return_day);
        tv_apply_return_reason = findViewById(R.id.tv_apply_return_reason);
        return_gridView = findViewById(R.id.return_gridView);


        tv_scrap_feedback_type = findViewById(R.id.tv_scrap_feedback_type);
        tv_apply_scrap_num = findViewById(R.id.tv_apply_scrap_num);
        tv_apply_scrap_day=findViewById(R.id.tv_apply_scrap_day);
        tv_apply_scrap_reason = findViewById(R.id.tv_apply_scrap_reason);
        scrap_gridView = findViewById(R.id.scrap_gridView);

    }

    @Override
    protected void initData(Bundle savedInstanceState) {
        tv_title.setText(getResources().getString(R.string.produce_feedback));

        img_modify_plan.setImageResource(R.mipmap.icon_date_normal);
//        img_modify_plan.setEnabled(false);
//        img_modify_plan.setClickable(false);

        Intent intent = getIntent();
        if (null != intent) {
            workPartFeedbackResponse = (WorkPartFeedbackResponse) intent.getSerializableExtra(ConstantUtil.KEY_1);
        }



        if (workPartFeedbackResponse.getStatus() == CommonEnum.FeedbackStatus.WAIT_CONFIRM || workPartFeedbackResponse.getStatus() == CommonEnum.FeedbackStatus.WAIT_REPLY_CONFIRM) {
            ll_bottom.setVisibility(View.VISIBLE);
        } else if (workPartFeedbackResponse.getStatus() == CommonEnum.FeedbackStatus.CONFIRM_FINISH || workPartFeedbackResponse.getStatus() == CommonEnum.FeedbackStatus.REPLY_CONFIRM_FINISH) {
            ll_bottom.setVisibility(View.GONE);
        }

        tv_workpart_name.setText(workPartFeedbackResponse.getWorkPartName());
        tv_product_name.setText(" / " + workPartFeedbackResponse.getProductName());

        workPartFeedbackDetailPresenter = new WorkPartFeedbackDetailPresenter(this);
        workPartFeedbackDetailPresenter.workPartFeedbackDetail();

        productNormalFeedbackConfirmPresenter = new ProductNormalFeedbackConfirmPresenter(this);
        productUnusualFeedbackConfirmPresenter = new ProductUnusualFeedbackConfirmPresenter(this);
        productUnusualFeedbackReplyConfirmPresenter = new ProductUnusualFeedbackReplyConfirmPresenter(this);

        workPartDetailPresenter = new WorkPartDetailPresenter(this);
        workPartDetailPresenter.workPartDetail();
    }

    @Override
    public void setListener() {
        rl_back.setOnClickListener(this);
        tv_order_information.setOnClickListener(this);
        img_modify_plan.setOnClickListener(this);
        rl_plan_infor.setOnClickListener(this);
        btn_submit.setOnClickListener(this);

        normal_gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long l) {
                Intent intent = new Intent(ProduceFeedbackDetailsActivity.this, AvatarImageShowerActivity.class);
                intent.putExtra("imageUrl", workPartDailyFeedbackBean.getImgUrlList().get(position));
                startActivity(intent);
            }
        });

        machin_gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long l) {
                Intent intent = new Intent(ProduceFeedbackDetailsActivity.this, AvatarImageShowerActivity.class);
                intent.putExtra("imageUrl", workPartDailyFeedbackBean.getImgUrlList().get(position));
                startActivity(intent);
            }
        });

        return_gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long l) {
                Intent intent = new Intent(ProduceFeedbackDetailsActivity.this, AvatarImageShowerActivity.class);
                intent.putExtra("imageUrl", workPartDailyFeedbackBean.getImgUrlList().get(position));
                startActivity(intent);
            }
        });

        scrap_gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long l) {
                Intent intent = new Intent(ProduceFeedbackDetailsActivity.this, AvatarImageShowerActivity.class);
                intent.putExtra("imageUrl", workPartDailyFeedbackBean.getImgUrlList().get(position));
                startActivity(intent);
            }
        });
    }

    private void feedbackConfirm() {
        if (null != workPartFeedbackResponse) {
            CommonEnum.WorkPartType type = workPartFeedbackResponse.getType();
            if (null != type) {
                if (type == CommonEnum.WorkPartType.NORMAL) { // 正常反馈
                    productNormalFeedbackConfirmPresenter.productNormalFeedbackConfirm();

                } else if (type == CommonEnum.WorkPartType.UNUSUAL) { // 异常反馈
                    CommonEnum.FeedbackStatus unusualStatus = workPartFeedbackResponse.getStatus();
                    if (null != unusualStatus) {
                        if (unusualStatus == CommonEnum.FeedbackStatus.WAIT_CONFIRM) {
                            productUnusualFeedbackConfirmPresenter.productUnusualFeedbackConfirm();
                        } else if (unusualStatus == CommonEnum.FeedbackStatus.WAIT_REPLY_CONFIRM) {
                            productUnusualFeedbackReplyConfirmPresenter.productUnusualFeedbackReplyConfirm();
                        }
                    }

                }else if (type == CommonEnum.WorkPartType.APPLY_ADJUST) { // 申请调整
                    CommonEnum.FeedbackStatus unusualStatus = workPartFeedbackResponse.getStatus();
                    if (null != unusualStatus) {
                        productUnusualFeedbackConfirmPresenter.productUnusualFeedbackConfirm();
                    }

                }else if (type == CommonEnum.WorkPartType.APPLY_RETURN) { // 申请返工
                    CommonEnum.FeedbackStatus unusualStatus = workPartFeedbackResponse.getStatus();
                    if (null != unusualStatus) {
                        productUnusualFeedbackConfirmPresenter.productUnusualFeedbackConfirm();
                    }

                }else if (type == CommonEnum.WorkPartType.APPLY_SCRAP) { // 申请报废
                    CommonEnum.FeedbackStatus unusualStatus = workPartFeedbackResponse.getStatus();
                    if (null != unusualStatus) {
                        productUnusualFeedbackConfirmPresenter.productUnusualFeedbackConfirm();
                    }
                }
            }
        }
    }

    @Override
    public void widgetClick(View v) {
        Intent mIntent;
        switch (v.getId()) {
            case R.id.rl_back:
                finish();
                break;
            // 工单信息
            case R.id.tv_order_information:
                mIntent = new Intent(ProduceFeedbackDetailsActivity.this, ProduceWorkpartDetailActivity.class);
                mIntent.putExtra(ConstantUtil.KEY_1, workPartBean);
                mIntent.putExtra(ConstantUtil.KEY_2, workPartFeedbackResponse);
                startActivityForResult(mIntent,ConstantUtil.START_ACTIVITY_KEY_2);
                break;
            // 修改计划
            case R.id.img_modify_plan:
                mIntent = new Intent(ProduceFeedbackDetailsActivity.this, ProduceModifyPlanActivity.class);
                mIntent.putExtra(ConstantUtil.KEY_1, workPartFeedbackResponse);
                mIntent.putExtra(ConstantUtil.KEY_2, workPartDailyFeedbackBean);
                startActivityForResult(mIntent, ConstantUtil.START_ACTIVITY_KEY_1);
                break;
                // 计划信息
            case R.id.rl_plan_infor:
                mIntent = new Intent(ProduceFeedbackDetailsActivity.this, ProduceModifyPlanInformationActivity.class);
                mIntent.putExtra(ConstantUtil.KEY_1, workPartFeedbackResponse);
                mIntent.putExtra(ConstantUtil.KEY_2, workPartDailyFeedbackBean);
                startActivityForResult(mIntent, ConstantUtil.START_ACTIVITY_KEY_1);
                break;
            // 提交
            case R.id.btn_submit:
                feedbackConfirm();
                break;
        }
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        switch (requestCode) {
            case ConstantUtil.START_ACTIVITY_KEY_1:
                if (null != data) {
                    workPartBean = (WorkPartBean) data.getSerializableExtra(ConstantUtil.KEY_1);
                }
                break;
            case ConstantUtil.START_ACTIVITY_KEY_2:
                if (null != data) {
                    workPartDetailPresenter.workPartDetail();
                }
                break;
        }
        super.onActivityResult(requestCode, resultCode, data);
    }

    @Override
    public String getOrderId() {
        return workPartFeedbackResponse.getOrderId();
    }

    @Override
    public String getProductId() {
        return workPartFeedbackResponse.getProductId();
    }

    @Override
    public CommonEnum.WorkPartType getType() {
        CommonEnum.WorkPartType type = workPartFeedbackResponse.getType();
        if (null != type) {
            if (type == CommonEnum.WorkPartType.UNUSUAL) {
                return CommonEnum.WorkPartType.UNUSUAL;

            } else if (type == CommonEnum.WorkPartType.APPLY_ADJUST) {
                return CommonEnum.WorkPartType.APPLY_ADJUST;

            } else if (type == CommonEnum.WorkPartType.APPLY_RETURN) {
                return CommonEnum.WorkPartType.APPLY_RETURN;

            } else if (type == CommonEnum.WorkPartType.APPLY_SCRAP) {
                return CommonEnum.WorkPartType.APPLY_SCRAP;
            }
        }
        return null;
    }

    @Override
    public String getWorkPartFeedbackId() {
        return workPartFeedbackResponse.getWorkPartFeedbackId();
    }

    @Override
    public String getWorkPartId() {
        return workPartFeedbackResponse.getWorkPartId();
    }

    @Override
    public String getWorkPartOrderId() {
        return workPartFeedbackResponse.getWorkPartOrderId();
    }

    @Override
    public void getProductUnusualFeedbackReplyConfirmSuccessed() {
        if (null != workPartFeedbackResponse) {
            Intent mIntent = new Intent();
            setResult(ConstantUtil.START_ACTIVITY_KEY_1, mIntent);
            showToast("确认");
            finish();
        }
    }

    @Override
    public void getProductUnusualFeedbackReplyConfirmFailed(final String desc) {
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                showToast(desc);
            }
        });
    }

    @Override
    public void workPartDetailSueecssed(WorkPartBean workPartBean) {
        if (null != workPartBean) {
            this.workPartBean = workPartBean;
            int count = 0;
            try {
                WorkPartScheduleBean sbean = workPartBean.getScheduleBeanByTime(workPartDailyFeedbackBean.getFeedbackDate());
                if (sbean != null) {
                    count = sbean.getAmount();
                }
            } catch (Exception e) {
                e.printStackTrace();
                return;
            }

            tv_normal_plan_amount.setText(String.valueOf(count));
            tv_plan_amount.setText(String.valueOf(count));
        }
    }

    @Override
    public void workPartDetailFailed(final String desc) {
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                showToast(desc);
            }
        });
    }

    @Override
    public List<WorkPartScheduleBean> getWorkPartScheduleItemRequestList() {
        return workPartBean.workPartScheduleList;
    }

    @Override
    public void getProductUnusualFeedbackConfirmSuccessed() {
        CommonEnum.WorkPartType type = workPartFeedbackResponse.getType();
        // 异常反馈
        if (type == CommonEnum.WorkPartType.UNUSUAL) {
            Intent mIntent = new Intent();
            setResult(ConstantUtil.START_ACTIVITY_KEY_1, mIntent);
            showToast("确认");
            finish();

        }else if (type == CommonEnum.WorkPartType.APPLY_ADJUST) { // 申请调整
            btn_submit.setBackgroundResource(R.mipmap.btn_long_bg_gray);
            img_modify_plan.setImageResource(R.mipmap.icon_date_pressed);
            img_modify_plan.setEnabled(true);
            img_modify_plan.setClickable(true);

        }else if (type == CommonEnum.WorkPartType.APPLY_RETURN) { // 申请返工
            btn_submit.setBackgroundResource(R.mipmap.btn_long_bg_gray);
            img_modify_plan.setImageResource(R.mipmap.icon_date_pressed);
            img_modify_plan.setEnabled(true);
            img_modify_plan.setClickable(true);

        }else if (type == CommonEnum.WorkPartType.APPLY_SCRAP) { // 申请报废
            btn_submit.setBackgroundResource(R.mipmap.btn_long_bg_gray);
            img_modify_plan.setImageResource(R.mipmap.icon_date_pressed);
            img_modify_plan.setEnabled(true);
            img_modify_plan.setClickable(true);
        }
    }

    @Override
    public void getProductUnusualFeedbackConfirmFailed(final String desc) {
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                showToast(desc);
            }
        });
    }

    @Override
    public void getProductNormalFeedbackConfirmSuccessed() {
        Intent mIntent = new Intent();
        setResult(ConstantUtil.START_ACTIVITY_KEY_1, mIntent);
        showToast("确认");
        finish();
    }

    @Override
    public void getProductNormalFeedbackConfirmFailed(final String desc) {
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                showToast(desc);
            }
        });
    }

    @Override
    public void getWorkPartFeedbackDetailSuccessed(WorkPartDailyFeedbackBean workPartDailyFeedbackBean) {
        if (null != workPartDailyFeedbackBean) {
            this.workPartDailyFeedbackBean = workPartDailyFeedbackBean;

            CommonEnum.WorkPartType type = workPartFeedbackResponse.getType();
            if (null != type) {
                if (type == CommonEnum.WorkPartType.NORMAL) {
                    tv_normal_feedback_type.setText(getResources().getString(R.string.normal_feedback));

                    ll_normal_feedback.setVisibility(View.VISIBLE);
                    ll_plan_feedback.setVisibility(View.GONE);
                    ll_machin_feedback.setVisibility(View.GONE);
                    ll_apply_adjust.setVisibility(View.GONE);
                    ll_apply_return.setVisibility(View.GONE);
                    ll_apply_scrap.setVisibility(View.GONE);
                    ll_modify_plan.setVisibility(View.GONE);

//                tv_normal_plan_amount.setText(String.valueOf(count));
                    tv_normal_daily_output.setText(String.valueOf(workPartDailyFeedbackBean.getCompleteCount()));
                    tv_normal_feedback_content.setText(workPartDailyFeedbackBean.getFeedbackInfo());

                    gridAdapter = new GridAdapter(this);
                    gridAdapter.setData(workPartDailyFeedbackBean.getImgUrlList());
                    normal_gridView.setAdapter(gridAdapter);

                } else if (type == CommonEnum.WorkPartType.UNUSUAL) {

                    CommonEnum.WorkPartSubType subType = workPartDailyFeedbackBean.getSubType();
                    if (null != subType) {
                        if (subType == CommonEnum.WorkPartSubType.PLAN_UNUSUAL) {
                            tv_plan_feedback_type.setText(getResources().getString(R.string.unusual_feedback));
                            tv_plan_unusual_classify.setText(getResources().getString(R.string.plan_unusual));

                            ll_normal_feedback.setVisibility(View.GONE);
                            ll_plan_feedback.setVisibility(View.VISIBLE);
                            ll_machin_feedback.setVisibility(View.GONE);
                            ll_apply_adjust.setVisibility(View.GONE);
                            ll_apply_return.setVisibility(View.GONE);
                            ll_apply_scrap.setVisibility(View.GONE);
                            ll_modify_plan.setVisibility(View.GONE);

//                        tv_plan_amount.setText(String.valueOf(count));
                            tv_plan_daily_output.setText(String.valueOf(workPartDailyFeedbackBean.getCompleteCount()));
                            tv_plan_unfinished_reason.setText(workPartDailyFeedbackBean.getUnusualInfo());
                            tv_plan_advice.setText(workPartDailyFeedbackBean.getUnusualAdvice());

                        } else if (subType == CommonEnum.WorkPartSubType.PRODUCE_UNUSUAL) {
                            tv_machin_feedback_type.setText(getResources().getString(R.string.unusual_feedback));
                            tv_machin_unusual_classify.setText(getResources().getString(R.string.machin_unusual));

                            ll_normal_feedback.setVisibility(View.GONE);
                            ll_plan_feedback.setVisibility(View.GONE);
                            ll_machin_feedback.setVisibility(View.VISIBLE);
                            ll_apply_adjust.setVisibility(View.GONE);
                            ll_apply_return.setVisibility(View.GONE);
                            ll_apply_scrap.setVisibility(View.GONE);
                            ll_modify_plan.setVisibility(View.GONE);

                            tv_machin_unusual_reason.setText(workPartDailyFeedbackBean.getUnusualInfo());
                            tv_machin_day_number.setText(workPartDailyFeedbackBean.getUnusualDays() + "天");
                            tv_machin_advice.setText(workPartDailyFeedbackBean.getUnusualAdvice());

                            gridAdapter = new GridAdapter(this);
                            gridAdapter.setData(workPartDailyFeedbackBean.getImgUrlList());
                            machin_gridView.setAdapter(gridAdapter);
                        }
                    }
                } else if (type == CommonEnum.WorkPartType.APPLY_ADJUST) {
                    tv_adjust_feedback_type.setText(getResources().getString(R.string.application_adjustment));

                    ll_normal_feedback.setVisibility(View.GONE);
                    ll_plan_feedback.setVisibility(View.GONE);
                    ll_machin_feedback.setVisibility(View.GONE);
                    ll_apply_adjust.setVisibility(View.VISIBLE);
                    ll_apply_return.setVisibility(View.GONE);
                    ll_apply_scrap.setVisibility(View.GONE);
                    ll_modify_plan.setVisibility(View.VISIBLE);

                    tv_apply_adjust_day.setText(workPartDailyFeedbackBean.getApplyDays() + "天");
                    tv_apply_adjust_reason.setText(workPartDailyFeedbackBean.getFeedbackInfo());

                } else if (type == CommonEnum.WorkPartType.APPLY_RETURN) {
                    tv_return_feedback_type.setText(getResources().getString(R.string.application_rework));

                    ll_normal_feedback.setVisibility(View.GONE);
                    ll_plan_feedback.setVisibility(View.GONE);
                    ll_machin_feedback.setVisibility(View.GONE);
                    ll_apply_adjust.setVisibility(View.GONE);
                    ll_apply_return.setVisibility(View.VISIBLE);
                    ll_apply_scrap.setVisibility(View.GONE);
                    ll_modify_plan.setVisibility(View.VISIBLE);

                    tv_apply_return_num.setText(String.valueOf(workPartDailyFeedbackBean.getApplyAmount()));
                    tv_apply_return_day.setText(workPartDailyFeedbackBean.getApplyDays() + "天");
                    tv_apply_return_reason.setText(workPartDailyFeedbackBean.getFeedbackInfo());

                    gridAdapter = new GridAdapter(this);
                    gridAdapter.setData(workPartDailyFeedbackBean.getImgUrlList());
                    return_gridView.setAdapter(gridAdapter);

                } else if (type == CommonEnum.WorkPartType.APPLY_SCRAP) {
                    tv_scrap_feedback_type.setText(getResources().getString(R.string.application_scrap));

                    ll_normal_feedback.setVisibility(View.GONE);
                    ll_plan_feedback.setVisibility(View.GONE);
                    ll_machin_feedback.setVisibility(View.GONE);
                    ll_apply_adjust.setVisibility(View.GONE);
                    ll_apply_return.setVisibility(View.GONE);
                    ll_apply_scrap.setVisibility(View.VISIBLE);
                    ll_modify_plan.setVisibility(View.VISIBLE);

                    tv_apply_scrap_num.setText(String.valueOf(workPartDailyFeedbackBean.getApplyAmount()));
                    tv_apply_scrap_day.setText(workPartDailyFeedbackBean.getApplyDays() + "天");
                    tv_apply_scrap_reason.setText(workPartDailyFeedbackBean.getFeedbackInfo());

                    gridAdapter = new GridAdapter(this);
                    gridAdapter.setData(workPartDailyFeedbackBean.getImgUrlList());
                    scrap_gridView.setAdapter(gridAdapter);
                }
            }

            tv_submit_person.setText(workPartDailyFeedbackBean.getAccountName());
            tv_submit_time.setText(DateUtil.getYyyy_Mm_Dd(workPartDailyFeedbackBean.getFeedbackDate()));
        }
    }

    @Override
    public void getWorkPartFeedbackDetailFailed(final String desc) {
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                showToast(desc);
            }
        });
    }

    @Override
    public void showLoading() {

    }

    @Override
    public void hideLoading() {

    }
}
